| Conditions | 1 |
| Paths | 1 |
| Total Lines | 94 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | 'use strict'; |
||
| 3 | module.exports = function (grunt) { |
||
| 4 | // Time how long tasks take. Can help when optimizing build times |
||
| 5 | require('time-grunt')(grunt); |
||
| 6 | |||
| 7 | // Automatically load required grunt tasks |
||
| 8 | require('jit-grunt')(grunt, { |
||
| 9 | lockfile: 'grunt-lock' |
||
| 10 | }); |
||
| 11 | |||
| 12 | // Configurable paths |
||
| 13 | var config = { |
||
| 14 | resources_dir: 'Resources/', |
||
| 15 | public_dir: 'Resources/public/' |
||
| 16 | }; |
||
| 17 | |||
| 18 | // Define the configuration for all the tasks |
||
| 19 | grunt.initConfig({ |
||
| 20 | // Project settings |
||
| 21 | config: config, |
||
| 22 | |||
| 23 | //Prevent multiple grunt instances |
||
| 24 | lockfile: { |
||
| 25 | grunt: { |
||
| 26 | path: 'grunt.lock' |
||
| 27 | } |
||
| 28 | }, |
||
| 29 | |||
| 30 | // Watches files for changes and runs tasks based on the changed files |
||
| 31 | watch: { |
||
| 32 | gruntfile: { |
||
| 33 | files: ['Gruntfile.js'], |
||
| 34 | options: { |
||
| 35 | reload: true |
||
| 36 | } |
||
| 37 | }, |
||
| 38 | sass: { |
||
| 39 | files: ['<%= config.resources_dir %>/sass/{,*/}*.{scss,sass}'], |
||
| 40 | tasks: ['sass', 'postcss'] |
||
| 41 | } |
||
| 42 | }, |
||
| 43 | |||
| 44 | // Compiles Sass to CSS and generates necessary files if requested |
||
| 45 | sass: { |
||
| 46 | options: { |
||
| 47 | sourceMap: true, |
||
| 48 | sourceMapEmbed: true, |
||
| 49 | sourceMapContents: true, |
||
| 50 | includePaths: ['.'] |
||
| 51 | }, |
||
| 52 | dist: { |
||
| 53 | files: [{ |
||
| 54 | expand: true, |
||
| 55 | cwd: '<%= config.resources_dir %>/sass', |
||
| 56 | src: ['*.{scss,sass}'], |
||
| 57 | dest: '.tmp/css', |
||
| 58 | ext: '.css' |
||
| 59 | }] |
||
| 60 | } |
||
| 61 | }, |
||
| 62 | |||
| 63 | postcss: { |
||
| 64 | options: { |
||
| 65 | map: true, |
||
| 66 | processors: [ |
||
| 67 | // Add vendor prefixed styles |
||
| 68 | require('autoprefixer-core')({ |
||
| 69 | browsers: ['> 1%', 'last 3 versions', 'Firefox ESR', 'Opera 12.1'] |
||
| 70 | }) |
||
| 71 | ] |
||
| 72 | }, |
||
| 73 | dist: { |
||
| 74 | files: [{ |
||
| 75 | expand: true, |
||
| 76 | cwd: '.tmp/css/', |
||
| 77 | src: '{,*/}*.css', |
||
| 78 | dest: '<%= config.public_dir %>/css' |
||
| 79 | }] |
||
| 80 | } |
||
| 81 | } |
||
| 82 | }); |
||
| 83 | |||
| 84 | grunt.registerTask('serve', 'Start the server and preview your app', function () { |
||
| 85 | grunt.task.run([ |
||
| 86 | 'lockfile', |
||
| 87 | 'sass:dist', |
||
| 88 | 'postcss', |
||
| 89 | 'watch' |
||
| 90 | ]); |
||
| 91 | }); |
||
| 92 | |||
| 93 | grunt.registerTask('default', [ |
||
| 94 | 'serve' |
||
| 95 | ]); |
||
| 96 | }; |
||
| 97 |